import useRequest from "@/utils/request";

const request = useRequest({});
export function listCoupon(params: any) {
  return request.get("/cj-stadium/sys/coupon/page", {
    params,
  });
}

export function updateStatus(data: any) {
  return request.post("/cj-stadium/sys/coupon/toggleStatus", data);
}

// V2
// 查询优惠券列表分页
export function pageCoupon(params: any) {
  return request.get("/cj-stadium/sys/coupon/page", {
    params,
  });
}

// 查询优惠券列表
export function listCoupons(params: any) {
  return request.get("/cj-stadium/sys/coupon/list", {
    params,
  });
}

// 查询优惠券数量
export function countCoupon(params: any) {
  return request.get("/cj-stadium/sys/coupon/count", {
    params,
  });
}

// 查询优惠券详情
export function getCoupon(id: string | number) {
  return request.get("/cj-stadium/sys/coupon/" + id);
}
// 查询驳回的优惠券详情
export function getApprovalCoupon(id: string | number) {
  return request.get("/cj-stadium/sys/coupon/audit/" + id);
}
export function getPass(id: string | number) {
  return request.get("/cj-stadium/sys/pass/" + id);
}
export function getApprovalPass(id: string | number) {
  return request.get("/cj-stadium/sys/pass/audit/" + id);
}
// 新增优惠券
export function addCoupon(data: any) {
  return request.post("/cj-stadium/sys/coupon/audit/add", data);
}
// 新增卡券
export function addPass(data: any) {
  return request.post("/cj-stadium/sys/pass/add", data);
}
// 修改优惠券
export function updateCoupon(data: any) {
  return request.put("/cj-stadium/sys/coupon/audit/update", data);
}
// 修改卡券
export function updatePass(data: any) {
  return request.put("/cj-stadium/sys/pass/update", data);
}
// 优惠券查询场馆列表
export function couponShowList(params: any) {
  return request.get("/cj-stadium/sys/stadium/couponShowList", {
    params,
  });
}

// 优惠券查询小程序用户列表
export function couponShowUserList(params: any) {
  return request.get("/cj-user/sys/user/couponShowUserList", {
    params,
  });
}

// 优惠券新增小程序用户
export function couponAddUserData(data: any) {
  return request.post("/cj-user/sys/user/couponAddUserData", data);
}

// 优惠券查看发放用户
export function couponUserPage(params: any) {
  return request.get("/cj-stadium/sys/coupon/user/page", {
    params,
  });
}

// 优惠券修改发放用户券
export function updateCouponsUser(data: any) {
  return request.post("/cj-stadium/sys/couponUser/update", data);
}

// 优惠券启用停用
export function enableCoupon(id: string | number) {
  return request.put("/cj-stadium/sys/coupon/enable/" + id);
}

// 优惠券删除
export function deleteCoupon(ids: string | number) {
  return request.delete("/cj-stadium/sys/coupon/delete/" + ids);
}

// 优惠券批量发放
export function batchSend(data: any) {
  return request.post("/cj-stadium/sys/coupon/batchSend", data);
}

// 小程序领取优惠券
export function receiveCoupons(data: any) {
  return request.post("/cj-stadium/app/coupon/receive", data);
}

// 创建经销商标识
export function addCouponsDealer(data: any) {
  return request.post("/cj-stadium/sys/couponDealer/add", data);
}

// 创建优惠券二维码
export function addCouponsQrCode(data: any) {
  return request.post("/cj-stadium/sys/couponQrCode/add", data);
}

// 发放记录
export function sendHistory(params: any) {
  return request.get("/cj-stadium/sys/coupon/sendHistoryPage", {
    params,
  });
}

// 购买记录
export function payHistory(params: any) {
  return request.get("/cj-stadium/sys/coupon/payHistoryPage", {
    params,
  });
}

// 领取记录
export function receiveHistoryPage(params: any) {
  return request.get("/cj-stadium/sys/coupon/receiveHistoryPage", {
    params,
  });
}

// 兑换记录
export function exchangeHistoryPage(params: any) {
  return request.get("/cj-stadium/sys/coupon/exchangeHistoryPage", {
    params,
  });
}

// 卡券记录
export function cardHistoryPage(params: any) {
  return request.get("/cj-stadium/sys/coupon/cardHistoryPage", {
    params,
  });
}

// 优惠券卡券发放分页查询
export function cardPage(params: any) {
  return request.get("/cj-stadium/sys/couponUser/cardPage", {
    params,
  });
}

// 用户优惠券删除
export function deleteCouponsUser(ids: string | number) {
  return request.delete("/cj-stadium/sys/coupon/user/delete/" + ids);
}

// 用户发放优惠券删除
export function deleteCouponsApply(ids: string | number) {
  return request.delete("/cj-stadium/sys/couponApply/delete/" + ids);
}

// 用户优惠查询使用记录分页查询
export function usePage(params: any) {
  return request.get("/cj-stadium/sys/couponWriterRecord/usePage", {
    params,
  });
}

// 查询发布优惠券的使用规则-最新一条
export function getGrantCouponData(params: any) {
  return request.get("/cj-stadium/sys/coupon/getCouponPublishConfig", {
    params,
  });
}

// 发布优惠券
export function grantCoupon(data: any) {
  return request.post("/cj-stadium/sys/coupon/publishCoupon", data);
}

// 取消发布优惠券-临时数据删除
export function cancelGrantCoupon(params: any) {
  return request.get("/cj-stadium/sys/coupon/cancelPublish", {
    params,
  });
}

// 创建优惠券二维码返回链接
export function createCouponQrCode(data: any) {
  return request.post("/cj-stadium/sys/couponQrCode/createQrCode", data);
}